From fb6e1a7ed108f115aa0f50500f90bcd52e5dbda3 Mon Sep 17 00:00:00 2001 From: "sos22@douglas.cl.cam.ac.uk" Date: Wed, 27 Jul 2005 10:52:29 +0000 Subject: [PATCH] Make sure that opt_nosmp also disables hyperthreading. This stops us from trying to create domains on non-existent threads, which would lead to a rather nasty crash. Signed-off-by: Steven Smith, sos22@cam.ac.uk --- xen/arch/x86/cpu/common.c | 9 +++++++-- xen/arch/x86/setup.c | 2 +- xen/common/domain.c | 3 ++- xen/common/sched_sedf.c | 3 +++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c index 49661af7d8..13628447aa 100644 --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -427,12 +427,17 @@ void __init detect_ht(struct cpuinfo_x86 *c) u32 eax, ebx, ecx, edx; int index_msb, tmp; int cpu = smp_processor_id(); + extern int opt_nosmp; if (!cpu_has(c, X86_FEATURE_HT) || cpu_has(c, X86_FEATURE_CMP_LEGACY)) return; - cpuid(1, &eax, &ebx, &ecx, &edx); - smp_num_siblings = (ebx & 0xff0000) >> 16; + if (opt_nosmp) { + smp_num_siblings = 1; + } else { + cpuid(1, &eax, &ebx, &ecx, &edx); + smp_num_siblings = (ebx & 0xff0000) >> 16; + } if (smp_num_siblings == 1) { printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 1ca0ed7154..ed010f88dc 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -35,7 +35,7 @@ integer_param("xenheap_megabytes", opt_xenheap_megabytes); #endif /* opt_nosmp: If true, secondary processors are ignored. */ -static int opt_nosmp = 0; +int opt_nosmp = 0; boolean_param("nosmp", opt_nosmp); /* maxcpus: maximum number of CPUs to activate. */ diff --git a/xen/common/domain.c b/xen/common/domain.c index 1b42a17dca..94fa6f9f8b 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -31,6 +31,7 @@ struct domain *do_createdomain(domid_t dom_id, unsigned int cpu) struct domain *d, **pd; struct vcpu *v; + ASSERT(cpu_online(cpu)); if ( (d = alloc_domain_struct()) == NULL ) return NULL; @@ -41,7 +42,7 @@ struct domain *do_createdomain(domid_t dom_id, unsigned int cpu) d->domain_id = dom_id; v->processor = cpu; - + spin_lock_init(&d->big_lock); spin_lock_init(&d->page_alloc_lock); diff --git a/xen/common/sched_sedf.c b/xen/common/sched_sedf.c index 1b7ac0cbf4..5a9d69b668 100644 --- a/xen/common/sched_sedf.c +++ b/xen/common/sched_sedf.c @@ -1225,6 +1225,9 @@ void sedf_wake(struct vcpu *d) { /*check whether the awakened task needs to invoke the do_schedule routine. Try to avoid unnecessary runs but: Save approximation: Always switch to scheduler!*/ + ASSERT(d->processor >= 0); + ASSERT(d->processor < NR_CPUS); + ASSERT(schedule_data[d->processor].curr); if (should_switch(schedule_data[d->processor].curr, d, now)) cpu_raise_softirq(d->processor, SCHEDULE_SOFTIRQ); } -- 2.30.2